home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 24 / AACD 24.iso / AACD / Online / Epic4 / share / epic / help / 5_programming / for < prev    next >
Encoding:
Text File  |  2001-03-21  |  1.5 KB  |  41 lines

  1. Synopsis:
  2.    for ([<pre>],[<condition>],[<post>]) { <action> }
  3.  
  4. Description:
  5.    FOR is a general purpose loop.  It is modeled on the C for statement,
  6.    and works in a very similar manner.  Aside from the action, there are
  7.    three parts to a FOR loop:
  8.  
  9.    * The "pre" part is executed before the loop begins iterating.  This is
  10.      often used for initializing counters and other variables that will be
  11.      used in the loop.
  12.  
  13.    * Before each loop iteration, the "condition" is checked.  Most often,
  14.      this is used to see if the counter has exceeded a certain limit.  The
  15.      condition may contain any expression legal in the IF command.
  16.      Because of this, the loop does not necessarily have to iterate at all.
  17.  
  18.    * The "post" part is executed after the condition, if the condition
  19.      returns true.  This is generally used to increment a counter that
  20.      gets checked by the condition statement.
  21.  
  22.    Multiple commands may be used in each part; they must be separated by
  23.    semicolons (giving it something of a reverse-C syntax).  Note that
  24.    there does not necessarily need to be any commands in any part.  The
  25.    action is optional as well.
  26.  
  27. Examples:
  28.    To display a warning message 3 times:
  29.       for ( @ xx = 3, xx > 0, @ xx-- ) {
  30.          echo WARNING!  This ship will self destruct in $xx seconds!
  31.       }
  32.  
  33.    A infinite loop that behaves like the Unix 'yes' command:
  34.       for ( ,, ) {
  35.          echo yes
  36.       }
  37.  
  38. See Also:
  39.    fe(5); fec(5); foreach(5); until(5); while(5)
  40.  
  41.